package com.example.administrator.ygddriver.tool;

import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.example.administrator.ygddriver.R;
import com.lzy.imagepicker.loader.ImageLoader;

import java.io.File;

public class GlideImageLoader implements ImageLoader {

    @Override
    public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
        RequestOptions requestOptions = new RequestOptions()
                .placeholder(R.mipmap.photo_null)
                .error(R.mipmap.photo_null)
                .skipMemoryCache(true)
                .diskCacheStrategy( DiskCacheStrategy.NONE )
                .fallback(R.mipmap.photo_null);


        Glide.with(activity)
                .load(Uri.fromFile(new File(path)))
                .apply(requestOptions)
                .into(imageView);
    }

    @Override
    public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
        RequestOptions requestOptions = new RequestOptions()
                .placeholder(R.mipmap.photo_null)
                .error(R.mipmap.photo_null)
                .skipMemoryCache(true)
                .diskCacheStrategy( DiskCacheStrategy.NONE )
                .fallback(R.mipmap.photo_null);

        Glide.with(activity)
                .load(Uri.fromFile(new File(path)))
                .apply(requestOptions)
                .into(imageView);
    }

    @Override
    public void clearMemoryCache() {

    }
}
